import request from '@/router/axios';
import config from '@/config/website'


//列表
export const materialList = (current, size, mold) => {
  return request({
    url: '/api/materialinfo/page',
    method: 'get',
    params: {
      current,
      size,
      ...mold
    }
  })
}
//不分页
export const getMaterialList = (mold) => {
  return request({
    url: '/api/materialinfo/list',
    method: 'get',
    params: {
      ...mold
    }
  })
}
//添加
export const materialAdd = (mold) => {
  return request({
    url: '/api/materialinfo/save',
    method: 'post',
    data: mold
  })
}

//编辑时获取数据
export const materialDetail = (id) => {
  return request({
    url: '/api/materialinfo/detail',
    method: 'get',
    params: {
      id
    }
  })
}

//根据材料名称  搜索材料下列选项
export const searchMaterial = (materialName) => {
  return request({
    url: '/api/materialinfo/rawmateriallist',
    method: 'get',
    params: {
      materialName
    }
  })
}
//编辑
export const materialUpdate = (mold) => {
  return request({
    url: '/api/materialinfo/update',
    method: 'post',
    data: mold
  })
}
//删除
export const removematerial = (ids) => {
  return request({
    url: '/api/materialinfo/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

//产品主数据导入
export const productInforImport = (fileUrl) => {
  return request({
    url: '/api/human-resources/personnel/personnelInfo/importFile',
    method: 'get',
    params: {
      fileUrl
    }
  })
}

//导出
export const materialInforExport = (ids) => {
  window.location = `${config.exportUrl}/material/downloadMaterial?id=${ids}`;
}
